package com.suixingfu.dao;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper;

import com.suixingfu.vo.FukuanVo;
import com.suixingfu.vo.UserVo;

public class UserDao implements UserImpl{
	private JdbcTemplate jdbcTemplate;
	
	public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}
	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}
	
	/*
	 * 查询信息
	 */
	@Override
	public UserVo select(String clientId) {
		// TODO Auto-generated method stub
		String sql="select * from user where clientId=?";
		try{
			return jdbcTemplate.queryForObject(sql, ParameterizedBeanPropertyRowMapper.newInstance(UserVo.class),clientId);
		}catch(Exception e){
			return null;
		}
	}
	
	/*
	 * 更新信息
	 */
	@Override
	public int update(UserVo uservo) {
		// TODO Auto-generated method stub
		String sql="update user set fukuanPsw=? where clientId=?";
		return jdbcTemplate.update(sql,uservo.getFukuanPsw(),uservo.getClientId());
	}

}
